home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gcc / ixemlsrc.lha / ixemul / string / rindex.c < prev    next >
C/C++ Source or Header  |  1996-03-13  |  2KB  |  42 lines

  1. /*-
  2.  * Copyright (c) 1990 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * This code is derived from software contributed to Berkeley by
  6.  * the Systems Programming Group of the University of Utah Computer
  7.  * Science Department.
  8.  *
  9.  * Redistribution and use in source and binary forms are permitted
  10.  * provided that: (1) source distributions retain this entire copyright
  11.  * notice and comment, and (2) distributions including binaries display
  12.  * the following acknowledgement:  ``This product includes software
  13.  * developed by the University of California, Berkeley and its contributors''
  14.  * in the documentation or other materials provided with the distribution
  15.  * and in all advertising materials mentioning features or use of this
  16.  * software. Neither the name of the University nor the names of its
  17.  * contributors may be used to endorse or promote products derived
  18.  * from this software without specific prior written permission.
  19.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  20.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  21.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  22.  */
  23.  
  24. #include "defs.h"
  25.  
  26. ENTRY(rindex)
  27. ENTRY(strrchr)
  28. asm("
  29.     movl    sp@(4),a0    /* string */
  30.     movb    sp@(11),d0    /* char to look for */
  31.     subl    a1,a1        /* clear rindex pointer */
  32. rixloop:
  33.     cmpb    a0@,d0        /* found our char? */
  34.     jne    rixnope        /* no, check for null */
  35.     movl    a0,a1        /* yes, remember location */
  36. rixnope:
  37.     tstb    a0@+        /* null? */
  38.     jne    rixloop        /* no, keep going */
  39.     movl    a1,d0        /* return value */
  40.     rts
  41. ");
  42.